package alitaV.old;


import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;


import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class genericExp2 {
    public static void main(String[] args) throws  Exception{
        System.out.println(gen(6,Integer.class));
        System.out.println(gen(6,String.class));

    }

    public  static <X> X gen(int a ,Class<X> s) throws Exception {
        X x = null;
        try{

        }catch (Exception e){

        }


        List list = new ArrayList();
        if (s.isAssignableFrom(String.class)) {
            {
                for (int i = 0; i < a; i++) {
                    // String s1 = RandomStringUtils.randomAlphabetic(5);
                    //list.add("99");
                }
            }

        } else if (s.isAssignableFrom(Integer.class)) {
            //List list = new ArrayList();
//            {
//
//                for (int i = 0; i < a; i++)
//                    list.add(RandomUtils.nextInt());
//                //x = (X) list;
//            }
//

        }
        x = (X) list;
        return x;
    }
}